数组的length属性,字符串的length()方法,集合size()方法
数组求长度用length属性
字符串求长度用length()方法
集合求长度用size()方法
import java.util.ArrayList;
import java.util.List;
public class Length {
public static void main(String[] args) {
String[] strings = {"aaa","bbb","ccc"}; //数组求长度用length属性
String string = "aaabbbccc"; //字符串求长度用length()方法
List<Integer> list = new ArrayList<Integer>(); //集合求长度用size()方法
list.add(1);
System.out.println("String[].length="+strings.length);
System.out.println("String.length()="+string.length());
System.out.println("List.size()="+list.size());
}
}